<?php
/**
 *  * 系统-受国家计算机软件著作权保护 - !
 * =========================================================
 * Copy right 2018-2025 成都海之心科技有限公司, 保留所有权利。
 * ----------------------------------------------
 * 官方网址: http://www.ohyu.cn
 * 这不是一个自由软件！在未得到官方有效许可的前提下禁止对程序代码进行修改和使用。
 * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
 * =========================================================
 * User: ohyueo
 * Date: 2024/5/30
 * Time: 14:17
 */
namespace app\install\controller;
use think\facade\Db;
/**
 * 安装模块 - 生成API模块
 * Class Index
 * @package app\install\controller
 */
class GenerAdmin  extends ApiBase
{
    //初始化传值给prefix
    public function __construct($prefix,$oldprefix)
    {
        $this->prefix = $prefix;
        $this->oldprefix = $oldprefix;
    }
    //替换后台模块里面的内容
    public function createadminController()
    {
        //获取类名 第一个大写
        $prefix = ucfirst($this->prefix);
        //去掉下划线
        $className = str_replace('_','',$prefix);

        //旧的类名 第一个大写
        $oldprefix = ucfirst($this->oldprefix);
        //去掉下划线
        $oldclassName = str_replace('_','',$oldprefix);

        //将app/admin/controller/下面的oldclassName Browse.php改成 className Browse.php
        $oldcontrollerpath = app_path().'../admin/controller/Admin.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'Admin::',$className.'Admin::',$content);
            $content = str_replace("admin\models\\".$oldclassName.'Admin',"admin\models\\".$className.'Admin',$content);
            $content = str_replace($oldclassName.'AdminActionLog',$className.'AdminActionLog',$content);
            $content = str_replace($oldclassName.'AdminRole',$className.'AdminRole',$content);
            $content = str_replace($oldclassName.'AdminUserRole',$className.'AdminUserRole',$content);
            $content = str_replace($oldclassName.'AdminPermission',$className.'AdminPermission',$content);
            $content = str_replace($oldclassName.'AdminRolePermission',$className.'AdminRolePermission',$content);
            $content = str_replace($this->oldprefix.'admin_role',$this->prefix.'admin_role',$content);
            $content = str_replace($this->oldprefix.'admin_user_role',$this->prefix.'admin_user_role',$content);
            $content = str_replace($this->oldprefix.'admin_permission',$this->prefix.'admin_permission',$content);
            $content = str_replace($this->oldprefix.'admin_role_permission',$this->prefix.'admin_role_permission',$content);
            $content = str_replace($this->oldprefix.'admin',$this->prefix.'admin',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Autocurd.php
        $oldcontrollerpath = app_path().'../admin/controller/Autocurd.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            $content = str_replace("'".$oldclassName."'","'".$className."'",$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Call.php
        $oldcontrollerpath = app_path().'../admin/controller/Call.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            $content = str_replace($oldclassName.'CallCalllist',$className.'CallCalllist',$content);
            $content = str_replace($oldclassName.'CallOrder',$className.'CallOrder',$content);
            file_put_contents($oldcontrollerpath,$content);
        }
        
        //将app/admin/controller/下面的Common.php
        $oldcontrollerpath = app_path().'../admin/controller/Common.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Home.php
        $oldcontrollerpath = app_path().'../admin/controller/Home.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Set.php
        $oldcontrollerpath = app_path().'../admin/controller/Set.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'Admin',$className.'Admin',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Index.php
        $oldcontrollerpath = app_path().'../admin/controller/Index.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Login.php
        $oldcontrollerpath = app_path().'../admin/controller/Login.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的User.php
        $oldcontrollerpath = app_path().'../admin/controller/User.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            $content = str_replace($oldclassName.'UserAddress',$className.'UserAddress',$content);
            $content = str_replace($oldclassName.'UserCollect',$className.'UserCollect',$content);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            $content = str_replace($oldclassName.'UserLogin',$className.'UserLogin',$content);
            $content = str_replace($oldclassName.'UserInfo',$className.'UserInfo',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Wen.php
        $oldcontrollerpath = app_path().'../admin/controller/Wen.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改 WorkerTexter
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'WorkerTexter',$className.'WorkerTexter',$content);
            $content = str_replace($oldclassName.'WebText',$className.'WebText',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Wxopen.php
        $oldcontrollerpath = app_path().'../admin/controller/Wxopen.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改 WorkerTexter
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'MerchantMerlist',$className.'MerchantMerlist',$content);
            $content = str_replace($oldclassName.'WxopenDraft',$className.'WxopenDraft',$content);
            $content = str_replace($oldclassName.'WxopenGetauthorizerlist',$className.'WxopenGetauthorizerlist',$content);
            $content = str_replace($oldclassName.'WxopenCodelist',$className.'WxopenCodelist',$content);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Worker.php
        $oldcontrollerpath = app_path().'../admin/controller/Worker.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'MerchantMerlist',$className.'MerchantMerlist',$content);
            $content = str_replace($oldclassName.'WxopenDraft',$className.'WxopenDraft',$content);
            $content = str_replace($oldclassName.'WxopenGetauthorizerlist',$className.'WxopenGetauthorizerlist',$content);
            $content = str_replace($oldclassName.'WxopenCodelist',$className.'WxopenCodelist',$content);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Zong.php
        $oldcontrollerpath = app_path().'../admin/controller/Zong.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'ZongheImg',$className.'ZongheImg',$content);
            $content = str_replace($oldclassName.'NotiList',$className.'NotiList',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Pay.php
        $oldcontrollerpath = app_path().'../admin/controller/Pay.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'PayRefund',$className.'PayRefund',$content);
            $content = str_replace($oldclassName.'PayIncome',$className.'PayIncome',$content);
            $content = str_replace($oldclassName.'PayPayorder',$className.'PayPayorder',$content);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            $content = str_replace($oldclassName.'UserIntegral',$className.'UserIntegral',$content);
            $content = str_replace($oldclassName.'UserMoneylog',$className.'UserMoneylog',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/controller/下面的Message.php
        $oldcontrollerpath = app_path().'../admin/controller/Message.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($oldclassName.'Message',$className.'Message',$content);
            $content = str_replace($oldclassName.'MessageText',$className.'MessageText',$content);
            $content = str_replace($oldclassName.'Sysmessage',$className.'Sysmessage',$content);
            file_put_contents($oldcontrollerpath,$content);
        }

        //将app/admin/traits/下面的AdminAuth.php
        $oldcontrollerpath = app_path().'../admin/traits/AdminAuth.php';
        //oldcontrollerpath文件存在则修改
        if(file_exists($oldcontrollerpath)){
            //将文件内容里面的类名修改
            $content = file_get_contents($oldcontrollerpath);
            $content = str_replace($this->oldprefix,$this->prefix,$content);
            file_put_contents($oldcontrollerpath,$content);
        }

    }

    //替换后台模型里面的内容
    public function createadminModel()
    {
        //获取类名 第一个大写
        $prefix = ucfirst($this->prefix);
        //去掉下划线
        $className = str_replace('_','',$prefix);

        //旧的类名 第一个大写
        $oldprefix = ucfirst($this->oldprefix);
        //去掉下划线
        $oldclassName = str_replace('_','',$oldprefix);

        //将app/api/models/下面的oldclassName NotiList.php改成 className NotiList.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'CallOrder.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'CallOrder.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'CallOrder',$className.'CallOrder',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/api/models/下面的oldclassName NotiList.php改成 className NotiList.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'CallCalllist.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'CallCalllist.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'CallCalllist',$className.'CallCalllist',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName NotiList.php改成 className NotiList.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'Admin.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'Admin.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'Admin',$className.'Admin',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName AdminActionLog.php改成 className AdminActionLog.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'AdminActionLog.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'AdminActionLog.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'AdminActionLog',$className.'AdminActionLog',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName AdminPermission.php改成 className AdminPermission.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'AdminPermission.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'AdminPermission.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'AdminPermission',$className.'AdminPermission',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName AdminRole.php改成 className AdminRole.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'AdminRole.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'AdminRole.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'AdminRole',$className.'AdminRole',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName AdminRolePermission.php改成 className AdminRolePermission.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'AdminRolePermission.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'AdminRolePermission.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'AdminRolePermission',$className.'AdminRolePermission',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName AdminUserRole.php改成 className AdminUserRole.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'AdminUserRole.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'AdminUserRole.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'AdminUserRole',$className.'AdminUserRole',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName NotiList.php改成 className NotiList.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'NotiList.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'NotiList.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'NotiList',$className.'NotiList',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserAddress.php改成 className UserAddress.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserAddress.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserAddress.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserAddress',$className.'UserAddress',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserCollect.php改成 className UserCollect.php   
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserCollect.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserCollect.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserCollect',$className.'UserCollect',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserList.php改成 className UserList.php 
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserList.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserList.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserList',$className.'UserList',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserLogin.php改成 className UserLogin.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserLogin.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserLogin.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserLogin',$className.'UserLogin',$content);
            file_put_contents($newmodelPath,$content);
        }


        //将app/admin/models/下面的oldclassName UserInfo.php改成 className UserInfo.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserInfo.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserInfo.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserInfo',$className.'UserInfo',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserIntegral.php改成 className UserIntegral.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserIntegral.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserIntegral.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserIntegral',$className.'UserIntegral',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName UserMoneylog.php改成 className UserMoneylog.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'UserMoneylog.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'UserMoneylog.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'UserMoneylog',$className.'UserMoneylog',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WebText.php改成 className WebText.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WebText.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WebText.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WebText',$className.'WebText',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WorkerTexter.php改成 className WorkerTexter.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WorkerTexter.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WorkerTexter.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WorkerTexter',$className.'WorkerTexter',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName ZongheImg.php改成 className ZongheImg.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'ZongheImg.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'ZongheImg.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'ZongheImg',$className.'ZongheImg',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WxopenAuthinfo.php改成 className WxopenAuthinfo.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WxopenAuthinfo.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WxopenAuthinfo.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WxopenAuthinfo',$className.'WxopenAuthinfo',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WxopenDraft.php改成 className WxopenDraft.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WxopenDraft.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WxopenDraft.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WxopenDraft',$className.'WxopenDraft',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WxopenGetauthorizerlist.php改成 className WxopenGetauthorizerlist.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WxopenGetauthorizerlist.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WxopenGetauthorizerlist.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WxopenGetauthorizerlist',$className.'WxopenGetauthorizerlist',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName WxopenCodelist.php改成 className WxopenCodelist.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'WxopenCodelist.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'WxopenCodelist.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'WxopenCodelist',$className.'WxopenCodelist',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName PayIncome.php改成 className PayIncome.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'PayIncome.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'PayIncome.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'PayIncome',$className.'PayIncome',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName PayPayorder.php改成 className PayPayorder.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'PayPayorder.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'PayPayorder.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'PayPayorder',$className.'PayPayorder',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName PayRefund.php改成 className PayRefund.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'PayRefund.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'PayRefund.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'PayRefund',$className.'PayRefund',$content);
            file_put_contents($newmodelPath,$content);
        }

        //将app/admin/models/下面的oldclassName Message.php改成 className Message.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'Message.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'Message.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'Message',$className.'Message',$content);
            file_put_contents($newmodelPath,$content);
        }
        //将app/admin/models/下面的oldclassName MessageText.php改成 className MessageText.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'MessageText.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'MessageText.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'MessageText',$className.'MessageText',$content);
            file_put_contents($newmodelPath,$content);
        }
        //将app/admin/models/下面的oldclassName Sysmessage.php改成 className Sysmessage.php
        $oldmodelpath = app_path().'../admin/models/'.$oldclassName.'Sysmessage.php';
        $newmodelPath = app_path().'../admin/models/'.$className.'Sysmessage.php';
        //oldmodelpath文件存在则修改
        if(file_exists($oldmodelpath)){
            //修改文件名称
            rename($oldmodelpath,$newmodelPath);
            //将文件内容里面的类名修改
            $content = file_get_contents($newmodelPath);
            $content = str_replace($oldclassName.'Sysmessage',$className.'Sysmessage',$content);
            file_put_contents($newmodelPath,$content);
        }

    }

}